package com.mszlu.news.controller;

import com.mszlu.news.service.GoodService;
import com.mszlu.news.vo.Result;
import com.mszlu.news.vo.params.CollectParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "点赞接口")
@RestController
@RequestMapping("good")
public class GoodController {
    @Autowired
    private GoodService goodService;

    @ApiOperation(value = "通过用户id查找点赞过的文章详情")
    @PostMapping("list/{userId}")
    public Result listGood(@PathVariable("userId") Long userId) {
        return goodService.listGoodByUserId(userId);
    }

    @ApiOperation(value = "点赞")
    @PostMapping("add")
    public Result addGood(@RequestBody CollectParam collectParam){
        return goodService.addGood(collectParam);
    }

    @ApiOperation(value = "删除赞")
    @PostMapping("delete")
    public Result deleteGood(@RequestBody CollectParam collectParam){
        return goodService.deleteGood(collectParam);
    }

    @ApiOperation(value = "通过文章id查找文章点赞个数")
    @PostMapping("count/{articleId}")
    public Result GoodCounts(@PathVariable("articleId") Long articleId) {
        return goodService.GoodCounts(articleId);
    }

    @ApiOperation(value = "通过用户id查找用户获赞数")
    @PostMapping("goodcount/{userId}")
    public Result GoodCounts1(@PathVariable("userId") Long userId) {
        return goodService.GoodCounts1(userId);
    }
}
